package com.eboss2.sbs.weight;

import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.eboss2.sbs.R;
import com.eboss2.sbs.activity.ActivitySmrz;
import com.eboss2.sbs.interfaces.EditPriceCallbackListener;
import com.eboss2.sbs.interfaces.EmsCallbackListener;
import com.eboss2.sbs.interfaces.RefundCallbackListener;
import com.tool.utils.utils.StringUtils;
import com.tool.utils.utils.ToastUtils;
import com.tool.utils.utils.UtilPreference;
import com.tool.utils.view.DecimalDigitsInputFilter;
import com.tool.utils.view.MoneyEditText;

/**
 * Created by Administrator on 2017/12/14 0014.
 */

public class DialogUtils {


    private static MyCustomDialog Dialog;

    private Callback listener;

    public interface Callback {
        void getData(String data, MyCustomDialog dialog);
    }


    public static MyCustomDialog showDialog(final Context mContext, String title, String bottom, Bitmap bitmap){
        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.dialog_share_qrcode, null);
        TextView tv_title = view.findViewById(R.id.title);
        tv_title.setText(title);
        TextView tv_bottom = view.findViewById(com.tool.R.id.bottom);
        tv_bottom.setText(bottom);
        ImageView img = (ImageView)view.findViewById(com.tool.R.id.img_qrcode);
        img.setImageBitmap(bitmap);


        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
        customBuilder.setCanceledOnTouchOutside(true);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        customBuilder.setDisBottomButton(true);
        // 2线在下方
        MyCustomDialog dialog = customBuilder.create();
        dialog.show();
        return dialog;
    }

    public static void  showAddQrDialog(final Context mContext, String name,  final Callback listener){
        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.dialog_add_qr, null);
        TextView tv_title = view.findViewById(R.id.tv_alert_dialog_title);
        TextView id_name = view.findViewById(R.id.id_name);
        id_name.setText(name);

        final EditText editText = view.findViewById(R.id.et_code_no);

        TextView btn_left = view.findViewById(R.id.btn_alert_dialog_btn_left);
        btn_left.setTextColor(mContext.getResources().getColorStateList(R.color.btn_left_selector));
        btn_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Dialog.dismiss();
            }
        });

        TextView btn_right = view.findViewById(R.id.btn_alert_dialog_btn_right);
        btn_right.setTextColor(mContext.getResources().getColorStateList(R.color.btn_right_selector));
        btn_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (StringUtils.isBlank(editText.getText().toString().trim())){
                    ToastUtils.CustomShow(mContext, "请输入验证码");
                    return;
                }
                if (listener != null){
                    Dialog.dismiss();
                    listener.getData(editText.getText().toString().trim(), Dialog);
                }
            }
        });

        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
//        customBuilder.setCancelable(false);
        customBuilder.setCanceledOnTouchOutside(false);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        customBuilder.setDisBottomButton(true);
        // 2线在下方
        Dialog = customBuilder.create();
        Dialog.show();
    }


    public static void  showComfirmProfitDialog(final Context mContext, String name,  final Callback listener){
        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.dialog_comfirm_profit, null);
        TextView tv_title = view.findViewById(R.id.tv_alert_dialog_title);
        TextView id_name = view.findViewById(R.id.id_detail);
        id_name.setText(name);

//        final EditText editText = view.findViewById(R.id.et_code_no);

        TextView btn_left = view.findViewById(R.id.btn_alert_dialog_btn_left);
        btn_left.setTextColor(mContext.getResources().getColorStateList(R.color.btn_left_selector));
        btn_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Dialog.dismiss();
            }
        });

        TextView btn_right = view.findViewById(R.id.btn_alert_dialog_btn_right);
        btn_right.setTextColor(mContext.getResources().getColorStateList(R.color.btn_right_selector));
        btn_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                if (StringUtils.isBlank(editText.getText().toString().trim())){
//                    ToastUtils.CustomShow(mContext, "请输入验证码");
//                    return;
//                }
//                if (listener != null){
//                    Dialog.dismiss();
//                    listener.getData(editText.getText().toString().trim());
//                }
            }
        });

        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
//        customBuilder.setCancelable(false);
        customBuilder.setCanceledOnTouchOutside(false);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        customBuilder.setDisBottomButton(true);
        // 2线在下方
        Dialog = customBuilder.create();
        Dialog.show();
    }

    public static void  showBackContentDialog(final Context mContext, String title, String msg, String content, final Callback listener){
        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.dialog_add_back, null);
        final TextView tvTitle = view.findViewById(R.id.tv_alert_dialog_title);
        final TextView id_detail = view.findViewById(R.id.id_detail);
        tvTitle.setText(title);
        id_detail.setText(msg);
        final EditText editText = view.findViewById(R.id.et_text);
        editText.setText(content);

        TextView btn_left = view.findViewById(R.id.btn_alert_dialog_btn_left);
        btn_left.setTextColor(mContext.getResources().getColorStateList(R.color.btn_left_blue_selector));
        btn_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Dialog.dismiss();
            }
        });

        TextView btn_right = view.findViewById(R.id.btn_alert_dialog_btn_right);
        btn_right.setTextColor(mContext.getResources().getColorStateList(R.color.btn_right_blue_selector));
        btn_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener != null){
//                    Dialog.dismiss();
                    listener.getData(editText.getText().toString().trim(), Dialog);
                }
            }
        });

        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
//        customBuilder.setCancelable(false);
        customBuilder.setCanceledOnTouchOutside(false);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        customBuilder.setDisBottomButton(true);
        // 2线在下方
        Dialog = customBuilder.create();
        Dialog.show();
    }

    public static void  showRefundDialog(final Context mContext, String title, String msg, String content, final Callback listener){
        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.dialog_refund, null);
        final TextView tvTitle = view.findViewById(R.id.tv_alert_dialog_title);
        final TextView id_detail = view.findViewById(R.id.id_detail);
        final TextView etContentLength = view.findViewById(R.id.tv_content_length);
        etContentLength.setText("输入数字0/300");
        tvTitle.setText(title);
        id_detail.setText(msg);
        final EditText editText = view.findViewById(R.id.et_text);
        editText.setText(content);

        editText.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                int count = s.length();
                etContentLength.setText("输入数字"+count+"/300");
            }
        });

        TextView btn_left = view.findViewById(R.id.btn_alert_dialog_btn_left);
        btn_left.setTextColor(mContext.getResources().getColorStateList(R.color.btn_left_blue_selector));
        btn_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Dialog.dismiss();
            }
        });

        TextView btn_right = view.findViewById(R.id.btn_alert_dialog_btn_right);
        btn_right.setTextColor(mContext.getResources().getColorStateList(R.color.btn_right_blue_selector));
        btn_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener != null){
//                    Dialog.dismiss();
                    listener.getData(editText.getText().toString().trim(), Dialog);
                }
            }
        });

        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
//        customBuilder.setCancelable(false);
        customBuilder.setCanceledOnTouchOutside(false);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        customBuilder.setDisBottomButton(true);
        // 2线在下方
        Dialog = customBuilder.create();
        Dialog.show();
    }


    public static void showDialogTb(final Context mContext, String typeStr, final Callback listener){


        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.alert_dialog2, null);

        TextView ll_title = view.findViewById(R.id.tv_alert_dialog_title);
        ll_title.setText("编辑库存");
        TextView tv_num = view.findViewById(R.id.tv_num);
        tv_num.setText(typeStr);

        final EditText editText = view.findViewById(R.id.et_card_no);
        editText.setFilters(new InputFilter[] {new DecimalDigitsInputFilter(2)});




        TextView btn_left = view.findViewById(R.id.btn_alert_dialog_btn_left);
        btn_left.setTextColor(mContext.getResources().getColorStateList(R.color.btn_left_selector));
        btn_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Dialog.dismiss();
            }
        });

        TextView btn_right = view.findViewById(R.id.btn_alert_dialog_btn_right);
        btn_right.setTextColor(mContext.getResources().getColorStateList(R.color.btn_right_blue_selector));
        btn_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                Dialog.dismiss();
                listener.getData(editText.getText().toString().trim(), Dialog);
            }
        });

        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
//        customBuilder.setCancelable(false);
        customBuilder.setCanceledOnTouchOutside(false);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        customBuilder.setDisBottomButton(true);
        // 2线在下方
        Dialog = customBuilder.create();
        Dialog.show();
    }

    public static void showDialogRefund(final Context mContext, String typeStr,final RefundCallbackListener listener){


        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.alert_dialog3, null);

        TextView ll_title = view.findViewById(R.id.tv_alert_dialog_title);
        ll_title.setText("确认退款");
        TextView tv_num = view.findViewById(R.id.tv_num);
        tv_num.setText(typeStr+"元");

        final MoneyEditText editText = (MoneyEditText)view.findViewById(R.id.et_card_no);
        final EditText etContent = view.findViewById(R.id.et_text);

        final String oldAmt = StringUtils.changeY2F(typeStr);



        TextView btn_left = view.findViewById(R.id.btn_alert_dialog_btn_left);
        btn_left.setTextColor(mContext.getResources().getColorStateList(R.color.btn_left_selector));
        btn_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Dialog.dismiss();
            }
        });

        TextView btn_right = view.findViewById(R.id.btn_alert_dialog_btn_right);
        btn_right.setTextColor(mContext.getResources().getColorStateList(R.color.btn_right_blue_selector));
        btn_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (StringUtils.isBlank(editText.getMoneyText().trim())){
                    ToastUtils.showShort(mContext, "金额不能为空");
                    return;
                }


                if (oldAmt.compareTo(StringUtils.changeY2F(editText.getMoneyText())) < 0){
                    ToastUtils.showShort(mContext, "退款金额不能大于原始支付金额");
                    return;
                }

                if(StringUtils.isBlank(etContent.getText().toString().trim())){
                    ToastUtils.showShort(mContext, "退款原因不能为空");
                    return;
                }



                listener.refundCallback(editText.getMoneyText().trim(), etContent.getText().toString().trim(), Dialog);
            }
        });

        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
//        customBuilder.setCancelable(false);
        customBuilder.setCanceledOnTouchOutside(false);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        customBuilder.setDisBottomButton(true);
        // 2线在下方
        Dialog = customBuilder.create();
        Dialog.show();
    }




    public static void  showEditPriceDialog(final Context mContext, Integer oldAmt, Integer emsAmt,final EditPriceCallbackListener listener){
        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.dialog_edit_price, null);

        final EditText et_good_amt = view.findViewById(R.id.et_good_amt);
        final EditText et_ems_amt = view.findViewById(R.id.et_ems_amt);
        final TextView tv_old_goods_amt = view.findViewById(R.id.tv_old_goods_amt);
        final TextView tv_old_ems_amt = view.findViewById(R.id.tv_old_ems_amt);
//        final TextView tv_old_pay_amt = view.findViewById(R.id.tv_old_pay_amt);
//        final TextView tv_ai_amt = view.findViewById(R.id.tv_ai_amt);
//        final TextView tv_cash_amt = view.findViewById(R.id.tv_cash_amt);

        tv_old_goods_amt.setText(StringUtils.formatIntMoney(oldAmt)+"元");
        tv_old_ems_amt.setText(StringUtils.formatIntMoney(emsAmt)+"元");

        TextView btn_left = view.findViewById(R.id.btn_alert_dialog_btn_left);
        btn_left.setTextColor(mContext.getResources().getColorStateList(R.color.btn_left_blue_selector));
        btn_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Dialog.dismiss();
            }
        });

        TextView btn_right = view.findViewById(R.id.btn_alert_dialog_btn_right);
        btn_right.setTextColor(mContext.getResources().getColorStateList(R.color.btn_right_blue_selector));
        btn_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener != null){
//                    Dialog.dismiss();
                    listener.getData(et_good_amt.getText().toString().trim(), et_ems_amt.getText().toString().trim(), "", Dialog);
                }
            }
        });

        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
//        customBuilder.setCancelable(false);
        customBuilder.setCanceledOnTouchOutside(false);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        customBuilder.setDisBottomButton(true);
        // 2线在下方
        Dialog = customBuilder.create();
        Dialog.show();
    }

    public static void  showSendGoodsDialog(final Context mContext, final EmsCallbackListener listener){
        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.dialog_ems_no, null);

        final EditText et_ems_no = view.findViewById(R.id.et_ems_no);
        final EditText et_ems_name = view.findViewById(R.id.et_ems_name);
        final ImageView iv_scan = view.findViewById(R.id.iv_scan);

//        et_ems_name.addTextChangedListener(new TextWatcher() {
//            @Override
//            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
//
//            }
//
//            @Override
//            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
//
//            }
//
//            @Override
//            public void afterTextChanged(Editable editable) {
//                listener.getEmsShortname(et_ems_name.getText().toString().trim());
//            }
//        });
//
//
//        iv_scan.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                listener.getScanData(et_ems_no);
//            }
//        });

        TextView btn_left = view.findViewById(R.id.btn_alert_dialog_btn_left);
        btn_left.setTextColor(mContext.getResources().getColorStateList(R.color.btn_left_blue_selector));
        btn_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Dialog.dismiss();
            }
        });

        TextView btn_right = view.findViewById(R.id.btn_alert_dialog_btn_right);
        btn_right.setTextColor(mContext.getResources().getColorStateList(R.color.btn_right_blue_selector));
        btn_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener != null){
//                    Dialog.dismiss();
                    listener.getData(et_ems_no.getText().toString().trim(), et_ems_name.getText().toString().trim(), Dialog);
                }
            }
        });

        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
//        customBuilder.setCancelable(false);
        customBuilder.setCanceledOnTouchOutside(false);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        customBuilder.setDisBottomButton(true);
        // 2线在下方
        Dialog = customBuilder.create();
        Dialog.show();
    }

    public static MyCustomDialog showDialog2(final Context mContext, String title, String leftText, String rightText, String content, String content2, View.OnClickListener leftClick, View.OnClickListener rightClick){
        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.alert_dialog, null);
        TextView tv_title = view.findViewById(R.id.tv_alert_dialog_title);
        tv_title.setText(title);
        tv_title.setBackgroundResource(R.drawable.bar_top_tips);
        tv_title.setTextColor(mContext.getResources().getColor(com.tool.R.color.white));

        TextView tv_content = view.findViewById(R.id.tv_alert_dialog_message);
        tv_content.setText(content);
        tv_content.setTextSize(18f);

        if (!StringUtils.isBlank(content2)) {
            TextView tv_content2 = view.findViewById(R.id.tv_alert_dialog_message2);
            tv_content2.setVisibility(View.VISIBLE);
            tv_content2.setText(content2);
        }


        TextView btn_left = view.findViewById(R.id.btn_alert_dialog_btn_left);
        btn_left.setText(leftText);
        btn_left.setTextColor(mContext.getResources().getColorStateList(R.color.btn_left_selector));
        btn_left.setOnClickListener(leftClick);

        TextView btn_right = view.findViewById(R.id.btn_alert_dialog_btn_right);
        btn_right.setText(rightText);
        btn_right.setTextColor(mContext.getResources().getColorStateList(R.color.btn_right_selector));
        btn_right.setOnClickListener(rightClick);

        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
//        customBuilder.setCancelable(false);
        customBuilder.setCanceledOnTouchOutside(false);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        customBuilder.setDisBottomButton(true);
        // 2线在下方
        MyCustomDialog dialog = customBuilder.create();
        dialog.show();
        return dialog;
    }


    public static MyCustomDialog showDialog3(final Context mContext, String title, String leftText, String rightText, String cardNo, String zd, String hk, String amt, View.OnClickListener leftClick, View.OnClickListener rightClick){
        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.alert_dialog4, null);
        TextView tv_title = view.findViewById(R.id.tv_alert_dialog_title);
        tv_title.setText(title);
        tv_title.setBackgroundResource(R.drawable.bar_top_tips);
        tv_title.setTextColor(mContext.getResources().getColor(com.tool.R.color.white));

        TextView tv_card_no = view.findViewById(R.id.tv_card_no);
        tv_card_no.setText(cardNo);

        TextView tv_zd_day = view.findViewById(R.id.tv_zd_day);
        tv_zd_day.setText(zd);

        TextView tv_hk_day = view.findViewById(R.id.tv_hk_day);
        tv_hk_day.setText(hk);

        TextView tv_bfj = view.findViewById(R.id.tv_bfj);
        tv_bfj.setText("信用卡备付金"+amt+"元");


        TextView btn_left = view.findViewById(R.id.btn_alert_dialog_btn_left);
        btn_left.setText(leftText);
        btn_left.setTextColor(mContext.getResources().getColorStateList(R.color.btn_left_selector));
        btn_left.setOnClickListener(leftClick);

        TextView btn_right = view.findViewById(R.id.btn_alert_dialog_btn_right);
        btn_right.setText(rightText);
        btn_right.setTextColor(mContext.getResources().getColorStateList(R.color.btn_right_selector));
        btn_right.setOnClickListener(rightClick);

        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
//        customBuilder.setCancelable(false);
        customBuilder.setCanceledOnTouchOutside(false);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        customBuilder.setDisBottomButton(true);
        // 2线在下方
        MyCustomDialog dialog = customBuilder.create();
        dialog.show();
        return dialog;
    }


    public static MyCustomDialog showDialogSuccess(final Context mContext, String title, String description, String account, String pwd, View.OnClickListener leftClick, View.OnClickListener rightClick){
        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.alert_dialog5, null);

        TextView tv_title = view.findViewById(R.id.tv_title);
        tv_title.setText(title);

        TextView tv_message = view.findViewById(R.id.tv_message);
        if (!StringUtils.isBlank(description)) {
            tv_message.setVisibility(View.VISIBLE);
            tv_message.setText(description);
        }else{
            tv_message.setVisibility(View.GONE);
        }

        TextView tv_account = view.findViewById(R.id.tv_account);
        tv_account.setText(account);

        // 从API11开始android推荐使用android.content.ClipboardManager
        // 为了兼容低版本我们这里使用旧版的android.text.ClipboardManager，虽然提示deprecated，但不影响使用。
        ClipboardManager cm = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
        // 将文本内容放到系统剪贴板里。
        cm.setText(tv_account.getText());
//        Toast.makeText(this, "复制成功，可以发给朋友们了。", Toast.LENGTH_LONG).show();



        TextView tv_pwd = view.findViewById(R.id.tv_pwd);
        tv_pwd.setText(pwd);




        TextView btn_left = view.findViewById(R.id.btn_alert_dialog_btn_left);
        btn_left.setText("确定");
        btn_left.setTextColor(mContext.getResources().getColorStateList(R.color.btn_left_selector));
        btn_left.setOnClickListener(leftClick);

        TextView btn_right = view.findViewById(R.id.btn_alert_dialog_btn_right);
        btn_right.setText("取消");
        btn_right.setTextColor(mContext.getResources().getColorStateList(R.color.btn_right_selector));
        btn_right.setOnClickListener(rightClick);

        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
//        customBuilder.setCancelable(false);
        customBuilder.setCanceledOnTouchOutside(false);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        customBuilder.setDisBottomButton(true);
        // 2线在下方
        MyCustomDialog dialog = customBuilder.create();
        dialog.show();
        return dialog;
    }

    public static boolean checkApproveStatus(final Context mContext){
        //判断是否实名认证
        int approve_status = UtilPreference.getIntValue(mContext, "approve_status");
        if (approve_status == 0 || approve_status == -1){
            showRegisterSuccess(mContext);
            return true;
        }
        return false;
    }

    private static void showRegisterSuccess(final Context mContext){

        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.dialog_register_success, null);
        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
        customBuilder.setCancelable(true);
        customBuilder.setCanceledOnTouchOutside(false);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        // 2线在下方
        customBuilder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog,
                                int which) {
                dialog.dismiss();
                mContext.startActivity(new Intent(mContext, ActivitySmrz.class));
            }
        });
        customBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog,
                                int which) {
                dialog.dismiss();
//                finish();
            }
        });
        final MyCustomDialog dialog = customBuilder.create();
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialogInterface) {
                //直接退出应用
                dialog.dismiss();
//                finish();
            }
        });
        dialog.show();
    }


    private static void RegisterSuccess(final Context mContext, String phone, String pwd, String description){

        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.dialog_register_success, null);
        final MyCustomDialog.Builder customBuilder = new MyCustomDialog.Builder(mContext,
                R.style.MyDialogStyleBottom);
        customBuilder.setCancelable(true);
        customBuilder.setCanceledOnTouchOutside(false);
        customBuilder.setLine(0);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方
        customBuilder.setContentView(view);
        // 2线在下方
        customBuilder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog,
                                int which) {
                dialog.dismiss();
                mContext.startActivity(new Intent(mContext, ActivitySmrz.class));
            }
        });
        customBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog,
                                int which) {
                dialog.dismiss();
//                finish();
            }
        });
        final MyCustomDialog dialog = customBuilder.create();
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialogInterface) {
                //直接退出应用
                dialog.dismiss();
//                finish();
            }
        });
        dialog.show();
    }


    /**
     * 显示消息 按钮为 确定 取消
     */
    public static void alert(String title, String hint, Context ctx, DialogInterface.OnClickListener positive,
                             DialogInterface.OnClickListener negative) {
        if (negative == null) {
            negative = new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                }
            };
        }
        alert(title, hint, ctx, "确定", "取消", positive, negative, null, true, true, 1);

    }



    // 最全的
    public static void alert(String title, String hint, Context ctx, String positiveText, String negativeText,
                             DialogInterface.OnClickListener positive, DialogInterface.OnClickListener negative, View view, boolean a,
                             boolean b, int line) {

        if (Dialog != null) {
            Dialog.dismiss();
            Dialog = null;
        }

        MyCustomDialog.Builder builder = new MyCustomDialog.Builder(ctx, com.tool.R.style.MyDialogStyleBottom);
        builder.setTitle(title);// 消息内容
        builder.setMessage(hint);// 提示补充
        builder.setContentView(view);// 自定义布局
        builder.setCancelable(a);
        builder.setCanceledOnTouchOutside(b);
        builder.setLine(line);// 分割横线所处位置 在自定义布局上下或隐藏 0隐藏 1线在上方 2线在下方

        builder.setPositiveButton(positiveText, positive);
        builder.setNegativeButton(negativeText, negative);
        Dialog = builder.create();

        Dialog.show();

    }

}
